
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>添加数据表 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    
    <link rel="prev" href="添加函数.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../快速使用.html">
            
                <a href="../快速使用.html">
            
                    
                    快速使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../函数及常量.html">
            
                <a href="../函数及常量.html">
            
                    
                    函数及常量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../BARRA因子.html">
            
                <a href="../BARRA因子.html">
            
                    
                    因子计算
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../已支持的表.html">
            
                <a href="../已支持的表.html">
            
                    
                    已支持的表
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../balance_sheet.html">
            
                <a href="../balance_sheet.html">
            
                    
                    balance_sheet
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../deriv_finance_indicator.html">
            
                <a href="../deriv_finance_indicator.html">
            
                    
                    deriv_finance_indicator
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../fundamentals_balance.html">
            
                <a href="../fundamentals_balance.html">
            
                    
                    fundamentals_balance
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../fundamentals_cashflow.html">
            
                <a href="../fundamentals_cashflow.html">
            
                    
                    fundamentals_cashflow
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../fundamentals_income.html">
            
                <a href="../fundamentals_income.html">
            
                    
                    fundamentals_income
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../share_change.html">
            
                <a href="../share_change.html">
            
                    
                    share_change
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="../trading_derivative_indicator.html">
            
                <a href="../trading_derivative_indicator.html">
            
                    
                    trading_derivative_indicator
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../项目说明.html">
            
                <a href="../项目说明.html">
            
                    
                    项目说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" >
            
                <span>
            
                    
                    参与项目开发
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="添加函数.html">
            
                <a href="添加函数.html">
            
                    
                    添加函数
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.7.2" data-path="添加数据表.html">
            
                <a href="添加数据表.html">
            
                    
                    添加数据表
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >添加数据表</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x6DFB;&#x52A0;&#x6570;&#x636E;&#x8868;">&#x6DFB;&#x52A0;&#x6570;&#x636E;&#x8868;</h1>
<p>&#x63A8;&#x8350;&#x7684;&#x65B9;&#x5F0F;&#x662F;&#x5728;<code>dataFile</code>&#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA;&#x6587;&#x4EF6;&#x5939;&#x547D;&#x540D;&#x4E3A;&#x8868;&#x540D;&#xFF0C;&#x5E76;&#x4EE5;<code>dataFile</code>&#x7684;&#x7EC4;&#x7EC7;&#x5F62;&#x5F0F;&#x8FDB;&#x884C;&#x6587;&#x4EF6;&#x7EC4;&#x7EC7;&#xFF0C;&#x6700;&#x540E;&#x4FEE;&#x6539;Utils.py&#x4E2D;&#x7684;<code>tableInfo</code></p>
<p>&#x4E0B;&#x9762;&#x4EE5;<strong>&#x8D22;&#x52A1;&#x884D;&#x751F;&#x6570;&#x636E; (Point in time)</strong>&#x4E3A;&#x4F8B;&#xFF0C;&#x5C55;&#x793A;&#x4E00;&#x4E2A;&#x5B8C;&#x6574;&#x6D41;&#x7A0B;</p>
<h2 id="&#x786E;&#x8BA4;&#x57FA;&#x672C;&#x60C5;&#x51B5;">&#x786E;&#x8BA4;&#x57FA;&#x672C;&#x60C5;&#x51B5;</h2>
<ul>
<li>&#x83B7;&#x53D6;&#x9014;&#x5F84;&#xFF1A;<strong>&#x8D22;&#x52A1;&#x884D;&#x751F;&#x6570;&#x636E; (Point in time)</strong>&#x901A;&#x8FC7;&#x901A;&#x8054;<code>API</code>&#x83B7;&#x53D6;</li>
<li><code>ts</code>&#x60C5;&#x51B5;&#xFF1A;&#x65F6;&#x95F4;&#x7D22;&#x5F15;&#x4E3A;<code>publishDate</code>&#xFF0C;&#x4E2A;&#x80A1;&#x7D22;&#x5F15;&#x4E3A;<code>ticker</code>&#xFF0C;&#x4E14;&#x4E3A;&#x80A1;&#x7968;&#x6570;&#x636E;</li>
<li>&#x6570;&#x636E;&#x5927;&#x5C0F;&#xFF1A;&#x6BCF;&#x80A1;&#x6BCF;&#x5E74;&#x53D1;&#x5E03;4-5&#x6B21;&#xFF0C;&#x6545;&#x4EE5;&#x6BCF;&#x5E74;&#x5F62;&#x5F0F;&#x7EC4;&#x7EC7;&#x5373;&#x53EF;</li>
</ul>
<h2 id="&#x5199;&#x5165;&#x6587;&#x4EF6;">&#x5199;&#x5165;&#x6587;&#x4EF6;</h2>
<p>&#x5199;&#x5165;&#x6587;&#x4EF6;&#x7684;<code>demo</code>&#x51FD;&#x6570;&#xFF0C;&#x5728;<code>Utils</code>&#x4E2D;&#x6709;&#x793A;&#x4F8B;&#xFF0C;&#x65E0;&#x6CD5;&#x8C03;&#x7528;&#xFF0C;&#x53EA;&#x80FD;&#x81EA;&#x5DF1;&#x6539;&#x5199;&#x8C03;&#x7528;&#xFF0C;&#x4EE5;&#x4E0B;&#x4E3A;&#x5E74;&#x5EA6;&#x5199;&#x5165;&#x793A;&#x4F8B;</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_per_year_data</span><span class="hljs-params">(year)</span>:</span>
    year_begin = format_date(str(year) + <span class="hljs-string">&apos;0101&apos;</span>)
    year_end = format_date(str(year) + <span class="hljs-string">&apos;1231&apos;</span>)
    <span class="hljs-keyword">return</span> DataAPI.FdmtDerPitGet(secID=<span class="hljs-string">&quot;&quot;</span>,ticker=<span class="hljs-string">&quot;&quot;</span>,beginDate=year_begin,endDate=year_end,beginYear=<span class="hljs-string">u&quot;&quot;</span>,endYear=<span class="hljs-string">u&quot;&quot;</span>,reportType=<span class="hljs-string">u&quot;&quot;</span>,publishDateEnd=<span class="hljs-string">u&quot;&quot;</span>,publishDateBegin=<span class="hljs-string">u&quot;&quot;</span>,field=<span class="hljs-string">u&quot;&quot;</span>,pandas=<span class="hljs-string">&quot;1&quot;</span>)

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">year_download_save</span><span class="hljs-params">()</span>:</span>
    <span class="hljs-keyword">for</span> year <span class="hljs-keyword">in</span> range(<span class="hljs-number">2015</span>, <span class="hljs-number">2024</span>):
        data = get_per_year_data(year)
        save_data_h5(data, <span class="hljs-string">&apos;FdmtDerPit_Y{}&apos;</span>.format(year), subPath=<span class="hljs-string">&apos;dataFile/FdmtDerPit&apos;</span>)
year_download_save()
</code></pre>
<p>&#x5B63;&#x5EA6;&#x5199;&#x5165;&#x53EF;&#x53C2;&#x7167;</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">quarter_download_save</span><span class="hljs-params">(year)</span>:</span>
    <span class="hljs-keyword">for</span> quarter <span class="hljs-keyword">in</span> range(<span class="hljs-number">0</span>, <span class="hljs-number">4</span>):
        quarter_begin_day = str(year) + quarter_begin[quarter]
        quarter_end_day = str(year) + quarter_end[quarter]
        data = DataAPI.FdmtDerPitGet(secCode=stockNumList,
                                     beginDate=quarter_begin_day,
                                     endDate=quarter_end_day, field=<span class="hljs-string">u&quot;&quot;</span>, pandas=<span class="hljs-string">&quot;1&quot;</span>)
        save_data_h5(data, name=<span class="hljs-string">&apos;ResConSecCorederi_Y{}_Q{}&apos;</span>.format(year, quarter + <span class="hljs-number">1</span>), subPath=<span class="hljs-string">&quot;dataFile/ResConSecCorederi&quot;</span>)
<span class="hljs-keyword">for</span> year <span class="hljs-keyword">in</span> tqdm(range(<span class="hljs-number">2015</span>,<span class="hljs-number">2024</span>)):
    quarter_download_save(year)
</code></pre>
<h2 id="&#x4FEE;&#x6539;tableinfo">&#x4FEE;&#x6539;<code>tableInfo</code></h2>
<p>&#x4E8E;<code>Euclid_get_data.py</code>&#x4E2D;&#xFF0C;&#x5BF9;<code>tableInfo</code>&#x589E;&#x6DFB;<code>item</code></p>
<p>&#x5176;&#x4E2D;<code>assets</code>&#x8868;&#x793A;&#x8D44;&#x4EA7;&#x7C7B;&#x578B;&#x4E3A;&#x80A1;&#x7968;&#x3001;<code>description</code>&#x53EF;&#x5199;&#x8868;&#x4ECB;&#x7ECD;&#x3001;<code>date_column</code>&#x6807;&#x8BB0;&#x4E86;&#x6570;&#x636E;&#x8868;&#x7684;&#x65F6;&#x95F4;&#x7D22;&#x5F15;&#x3001;<code>ticker_column</code>&#x6807;&#x8BB0;&#x4E2A;&#x80A1;&#x7D22;&#x5F15;</p>
<pre><code class="lang-python"><span class="hljs-string">&apos;FdmtDerPit&apos;</span>: {
        <span class="hljs-string">&apos;assets&apos;</span>: <span class="hljs-string">&apos;stock&apos;</span>,
        <span class="hljs-string">&apos;description&apos;</span>: <span class="hljs-string">&apos;&apos;</span>,
        <span class="hljs-string">&apos;date_column&apos;</span>: <span class="hljs-string">&apos;publishDate&apos;</span>,
        <span class="hljs-string">&apos;ticker_column&apos;</span>: <span class="hljs-string">&apos;ticker&apos;</span>
    }
</code></pre>
<h2 id="&#x8C03;&#x7528;&#x6D4B;&#x8BD5;">&#x8C03;&#x7528;&#x6D4B;&#x8BD5;</h2>
<p>&#x9700;&#x8C03;&#x7528;&#x6210;&#x529F;&#xFF0C;&#x624D;&#x80FD;&#x89C6;&#x4E3A;&#x6DFB;&#x52A0;&#x6210;&#x529F;&#xFF0C;&#x672A;&#x7ECF;&#x6D4B;&#x8BD5;&#x7684;&#x8868;&#x4E25;&#x7981;&#x6DFB;&#x52A0;&#x8FDB;<code>tableInfo</code></p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> Utils <span class="hljs-keyword">import</span> get_data

data = get_data(<span class="hljs-string">&apos;FdmtDerPit&apos;</span>, begin=<span class="hljs-string">&apos;20180101&apos;</span>, end=<span class="hljs-keyword">None</span>, ticker=<span class="hljs-string">&apos;000001&apos;</span>)
print(data.info())
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="添加函数.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: 添加函数">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"添加数据表","level":"1.7.2","depth":2,"previous":{"title":"添加函数","level":"1.7.1","depth":2,"path":"参与项目开发/添加函数.md","ref":"参与项目开发/添加函数.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"参与项目开发/添加数据表.md","mtime":"2023-04-14T08:19:31.511Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2023-07-01T05:15:14.464Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

